import 'package:flutter/material.dart';
import 'package:jingyuan/pages/book/PdfItem.dart';
import 'package:jingyuan/pages/book/pdfViewerPage.dart';

class BookTabPage extends StatefulWidget {
  BookTabPage({super.key});

  @override
  State<BookTabPage> createState() => _BookTabPageState();
}

class _BookTabPageState extends State<BookTabPage> {
  final _datas = [
    PdfItem(title: "佛說大乘無量壽莊嚴清淨平等覺經1", path: "assets/books/1_wuliangshoujing/1.pdf"),
    PdfItem(title: "佛說大乘無量壽莊嚴清淨平等覺經2", path: "assets/books/1_wuliangshoujing/2.pdf"),
  ];
  @override
  Widget build(BuildContext context) {
    return ListView.builder(
        itemCount: _datas.length,
        itemBuilder: (context, index) {
          var item = _datas[index % _datas.length];
          return GestureDetector(
            onTap: () {
              Navigator.push(
                context,
                MaterialPageRoute(
                    builder: (context) => PdfViewerPage(
                          data: item,
                        )),
              );
            },
            child: Container(
                padding: const EdgeInsets.only(left: 16, right: 16, top: 8, bottom: 8),
                height: 40,
                child: Row(
                  children: [
                    const Icon(Icons.picture_as_pdf),
                    const SizedBox(
                      width: 8,
                    ),
                    Expanded(
                        child: Text(
                      item.title,
                      overflow: TextOverflow.ellipsis,
                    ))
                  ],
                )),
          );
        });
  }
}
